﻿using System;

namespace WillsLLC.DbGen.Text.Inflection
{
    [Serializable]
    internal struct IrregularInflection
    {
        public IrregularInflection(String data)
            : this(data.Split(new Char[] { ' ' }, StringSplitOptions.None)) { }

        public IrregularInflection(String[] data)
        {
            _singular = data[0];
            _singularSuffix = data[1];
            _pluralSuffix = data[2];
        }
        private String _singular;
        private String _singularSuffix;
        private String _pluralSuffix;

        internal String Singular { get { return _singular; } }
        internal String SingularSuffix { get { return _singularSuffix; } }
        internal String PluralSuffix { get { return _pluralSuffix; } }

        public String GetPlural(String singular)
        {
            if (InflectionUtility.GetWordPattern(this._singular).IsMatch(singular))
            {
                return InflectionUtility.Inflect(singular, this._singularSuffix, this._pluralSuffix);
            }
            else return null;
        }
    }
}
